function getRandomDate() {
    // 获取当前日期
    var currentDate = new Date();

    // 计算 6 个月前的日期
    var sixMonthsAgo = new Date();
    sixMonthsAgo.setMonth(currentDate.getMonth() - 6);

    // 生成随机日期
    var randomDate = new Date(sixMonthsAgo.getTime() + Math.random() * (currentDate.getTime() - sixMonthsAgo.getTime()));

    // 格式化日期
    var formattedDate = randomDate.getFullYear() + '-' +
        ('0' + (randomDate.getMonth() + 1)).slice(-2) + '-' +
        ('0' + randomDate.getDate()).slice(-2) + ' ' +
        ('0' + randomDate.getHours()).slice(-2) + ':' +
        ('0' + randomDate.getMinutes()).slice(-2);  

    return formattedDate;
}
; (() => {
    const Random = Mock.Random
    const list = ["餐饮", "交通", "服饰", "购物", "服务", "教育", "娱乐", "运动", "生活缴费", "旅行", "宠物", "医疗", "保险", "公益", "发红包",
        "转账", "亲属卡", "其他人情", "其他", "退还"]
    const list1 = ['生意', '工资', '奖金', '其他人情', '收红包', '收转账', '商家转账', '退款', '其他']
    const length = list.length
    const gen = (len) => {
        let res = []
        for (let i = 0; i < len; i++) {
            const positive = Math.random() > .8
            const o = {
                id: i + 1,
                typeId: positive ? Random.natural(1, 9) : Random.natural(1, 20),
                positive, //true收入 false支出
                money: Random.float(0, 1000, 0, 2),
                remark: Random.ctitle(3, 20),
                risk: Random.natural(1, 4),
                date: getRandomDate(),
                img: 'https://picsum.photos/200'

            }
            res.push(o)
        }
        res.sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime())
        return res
    }
    console.log('gen()', gen(300))

    const genZhiChuType = () => {
        const r = []
        list.forEach((item, index) => {
            r.push({ id: index + 1, name: item })
        })
        return r
    }
    console.log('genZhiChuType', genZhiChuType())
    const genShouRuType = () => {
        const r = []
        list1.forEach((item, index) => {
            r.push({ id: index + 1, name: item })
        })
        return r
    }
    console.log('genShouRuType()', genShouRuType())
})();

